﻿@model OrderControllerModel.Detail
<div>
    <div class="ui-box  ui-box-alpha">
        <div class="ui-box-head">
            <div class="ui-box-head-border">
                <div class="ui-box-head-title">
                    订单中心</div>
                <span class="ui-box-head-text">@(Order.CategoryDic.FirstOrDefault(o => o.Key == Model.Order.Category).Value)</span>
                @if (Model.Order.Category == OrderCategory.Normal)
                {
                    <a href="#" class="ui-box-head-more">去购物</a>
                }
                else if (Model.Order.Category == OrderCategory.Auction)
                {
                    <a href="#" class="ui-box-head-more">去竞购</a>
                }
                else
                {
                    <a href="#" class="ui-box-head-more">去玩游戏</a>
                }
            </div>
        </div>
        <div class="ui-box-container">
            <div class="ui-box-content">
                @OrderDetail.GetStepHtml(Model.Order)
            </div>
        </div>
        <div class="ui-box-container">
            @OrderDetail.GetStatusHtml(Model.Order)
        </div>
        <div class="ui-box-container-noborder">
            <div class="ui-box-content">
                <p>
                    <strong>商家信息</strong></p>
                <div class="row">
                    <div class="col-md-6">
                        <p>
                            昵 称：@Model.Order.SellerNick</p>
                    </div>
                    <div class="col-md-6">
                        <p>
                            真实姓名：</p>
                    </div>
                    <div class="col-md-6">
                        <p>
                            所在地区：</p>
                    </div>
                    <div class="col-md-6">
                        <p>
                            联系电话：</p>
                    </div>
                </div>
                <p>
                    <strong>订单信息</strong><span style="margin-left: 10px;">@(Order.CategoryDic.FirstOrDefault(o => o.Key == Model.Order.Category).Value)</span></p>
                <div class="row">
                    <div class="col-md-6">
                        <p>
                            订单编号：<span>@Model.Order.Id</span>
                        </p>
                    </div>
                    <div class="col-md-6">
                        <p>
                            下单时间：<span>@Model.Order.CreatedOn.ToString("yyyy-MM-dd HH:mm:ss")</span>
                        </p>
                    </div>
                    @if (Model.Order.PayTime.HasValue)
                    { <div class="col-md-6">
                            <p>
                                付款时间：<span> @Model.Order.PayTime.ToString("yyyy-MM-dd HH:mm:ss", string.Empty)</span>
                            </p>
                        </div> }
                    @if (Model.Order.ConsignTime.HasValue)
                    {
                        <div class="col-md-6">
                            <p>
                                发货时间：<span> @Model.Order.ConsignTime.ToString("yyyy-MM-dd HH:mm:ss", string.Empty)</span>
                            </p>
                        </div>
                    }
                    @if (Model.Order.EndTime.HasValue)
                    {
                        <div class="col-md-6">
                            <p>
                                确认时间：<span> @Model.Order.EndTime.ToString("yyyy-MM-dd HH:mm:ss", string.Empty)</span>
                            </p>
                        </div>
                    }
                </div>
            </div>
            @if (Model.Order.Status == OrderStatus.Pending || Model.Order.Status == OrderStatus.WaitBuyerPay || Model.Order.Status == OrderStatus.WaitSellerSend)
            {
                <table class="ui-table ui-table-alpha" style="border: none;">
                    <thead>
                        <tr>
                            <th style="width: 250px;">
                                商 品
                            </th>
                            <th>
                                单价(元)
                            </th>
                            <th>
                                数 量
                            </th>
                            <th>
                                优惠(元)
                            </th>
                            <th>
                                赠积分
                            </th>
                            <th>
                                状 态
                            </th>
                            <th>
                                @if (Model.Order.Status == OrderStatus.Pending || Model.Order.Status == OrderStatus.WaitBuyerPay)
                                {
                                    @:小计(元)
                            }
                                else
                                {
                                    @:实付款(元)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            }
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        @Model.Order.OrderItems.Each(@<tr>
                            <td title="@(item.Item.Title)">
                                <div class="media">
                                    <a class="pull-left" href="@(string.Format("{0}/{1}.html", WebSite.Item, item.Item.Id))" target="_blank">
                                        <img data-src="holder.js/64x64" class="media-object" alt="64x64" style="width: 64px;
                                            height: 64px;" src="">
                                    </a>
                                    <div class="media-body">
                                        <h5 class="media-heading">
                                            @(item.Item.Title)</h5>
                                        <div>
                                            @foreach (var x in item.Item.GetProperties().OrderBy(x => x.Length))
                                            {
                                                <span>@x</span>
                                                <br />
                                            }
                                        </div>
                                    </div>
                                </div>
                            </td>
                            <td>
                                @(item.Item.Price.ToString("N"))
                            </td>
                            <td>
                                @item.Item.Quantity
                            </td>
                            <td>
                                @item.Item.Discount.ToString("N")
                            </td>
                            <td>
                            </td>
                            <td class="col">
                                @if (Model.Order.Status == OrderStatus.Pending || Model.Order.Status == OrderStatus.WaitBuyerPay)
                                {
                                    <span>待付款</span>
                                }
                                else if (Model.Order.Status == OrderStatus.WaitSellerSend)
                                {
                                    <span>已付款 待发货</span>
                                }
                                else if (Model.Order.Status == OrderStatus.Canceled)
                                {
                                    <p>
                                        <span>已取消<a style="margin-left: 5px;" href="javascript:void(0);" title="@(Model.Order.CancelText)取消原因：@(Model.Order.CancelReason)"><i
                                            class="icon-bookmark"></i> </a></span>
                                    </p>
                                }
                            </td>
                            @if (item.Index == 0)
                            {
                                <td rowspan ="@(Model.Order.OrderItems.Count + 1)" style="border-right: 1px solid #D9D9D9">
                                    <p>
                                        <strong>@(Model.Order.Total.ToString("N"))</strong></p>
                                    @if (Model.Order.Postage == 0)
                                    {
                                        <p>
                                            <span>免运费</span></p>
                                    }
                                    else
                                    {
                                        <p>
                                            <span>含快递：@(Model.Order.Postage.ToString("N"))</span></p>
                                    }
                                    <p>
                                        <span>订单优惠：@(Model.Order.Discount.ToString("N"))</span></p>
                                </td>
                               
                            }
                        </tr>)
                        <tr>
                            <td colspan="6" class="text-align-left" style="border-right: 1px solid #D9D9D9">
                                <p>
                                    收货人：@(Model.Order.Receiver)
                                    @(Model.Order.Mobile)
                                    @(Model.Order.Phone)
                                </p>
                                <p>
                                    收货地址：@(Model.Order.Province)
                                    @(Model.Order.City)
                                    @(Model.Order.District)
                                    @(Model.Order.Address)
                                    @(Model.Order.PostalCode)
                                </p>
                                @if (!Model.Order.Extra.IsNullOrEmpty())
                                {
                                    <p>
                                        我的备忘：@(Model.Order.Extra)
                                    </p>
                                }
                            </td>
                        </tr>
                    </tbody>
                    <tfoot>
                        <tr>
                            <td colspan="7">
                                <p>
                                    买家留言：@(Model.Order.BuyerMessage)
                                    @if (Model.Order.Status == OrderStatus.Pending || Model.Order.Status == OrderStatus.WaitBuyerPay)
                                    {
                                        <span title="付款前，您可以对留言信息进行修改补充。" style="margin-left: 20px;"><a data-trigger="modal" href="/order/message/@(Model.Order.Id)"
                                                                      data-title="修改补充留言">修改补充留言</a> </span>}
                                </p>
                                @if (Model.Order.Status == OrderStatus.Pending || Model.Order.Status == OrderStatus.WaitBuyerPay)
                                {
                                    <p class="pull-right">
                                        待付款： <span class="order-info-total-price">@(Model.Order.Total.ToString("N"))</span>元
                                    </p>
                                }
                                else if (Model.Order.Status == OrderStatus.WaitSellerSend)
                                {
                                    <p class="pull-right">
                                        实付款： <span class="order-info-total-price">@(Model.Order.Total.ToString("N"))</span>元
                                    </p>
                                }
                            </td>
                        </tr>
                    </tfoot>
                </table>
            }
            else if (Model.Order.Status == OrderStatus.SellerSendPart)
            {
                <table class="ui-table ui-table-alpha" style="border: none;">
                    <thead>
                        <tr>
                            <th style="width: 250px;">
                                商 品
                            </th>
                            <th>
                                单价(元)
                            </th>
                            <th>
                                数 量
                            </th>
                            <th>
                                优惠(元)
                            </th>
                            <th>
                                赠积分
                            </th>
                            <th>
                                状 态
                            </th>
                            <th>
                                实付款(元)
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        @{ var index = 1; }
                        @foreach (var o in Model.Shippings)
                        {
                            var ids = o.OrderItemIds.Split(',');
                            var items = Model.Order.OrderItems.Where(i => ids.Contains(i.Id.ToString().Trim())).ToList();
                            <tr>
                                <td colspan="6" class="text-align-left" style="border-right: 1px solid #D9D9D9">
                                    <strong>包裹 @index</strong> <span class="pull-right">运单号：<strong>@(o.ExpressNo)</strong></span>
                                </td>
                                @if (index == 1)
                                {
                                    <td rowspan="@(Model.Shippings.Count * 2 + Model.Order.OrderItems.Count + 1)" >
                                        <p>
                                            <strong>@(Model.Order.Total.ToString("N"))</strong></p>
                                        @if (Model.Order.Postage == 0)
                                        {
                                            <p>
                                                <span>免运费</span></p>
                                        }
                                        else
                                        {
                                            <p>
                                                <span>含快递：@(Model.Order.Postage.ToString("N"))</span></p>
                                        }
                                        <p>
                                            <span>订单优惠：@(Model.Order.Discount.ToString("N"))</span></p>
                                    </td>
                                }
                            </tr>
                            @items.Each(@<tr>
                                <td title="@(item.Item.Title)">
                                    <div class="media">
                                        <a class="pull-left" href="@(string.Format("{0}/{1}.html", WebSite.Item, item.Item.Id))" target="_blank">
                                            <img data-src="holder.js/64x64" class="media-object" alt="64x64" style="width: 64px;
                                                height: 64px;" src="">
                                        </a>
                                        <div class="media-body">
                                            <h5 class="media-heading">
                                                @(item.Item.Title)</h5>
                                            <div>
                                                @foreach (var x in item.Item.GetProperties().OrderBy(x => x.Length))
                                                {
                                                    <span>@x</span>
                                                    <br />
                                                }
                                            </div>
                                        </div>
                                    </div>
                                </td>
                                <td>
                                    @(item.Item.Price.ToString("N"))
                                </td>
                                <td>
                                    @item.Item.Quantity
                                </td>
                                <td>
                                    @item.Item.Discount.ToString("N")
                                </td>
                                <td>
                                </td>
                                <td style="border-right: 1px solid #D9D9D9">
                                    d
                                </td>
                            </tr>)
                            <tr>
                                <td colspan="6" class="text-align-left" style="border-right: 1px solid #D9D9D9">
                                    <p>
                                        收货人：@(o.Receiver)
                                        @(o.Mobile)
                                        @if (!o.Phone.IsNullOrEmpty())
                                        {
                                            @:（@(o.Phone)）
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            }
                                    </p>
                                    <p>
                                        收货地址：@(o.Province)
                                        @(o.City)
                                        @(o.District)
                                        @(o.Address)
                                        @(o.PostalCode)
                                    </p>
                                    <p>
                                        物流公司：@(o.Company)
                                    </p>
                                </td>
                            </tr>
                                        index += 1;
                        }
                        <tr>
                            <td style="border-right: 1px solid #D9D9D9" class="text-align-left" colspan="6">
                                <strong>以下商品暂未发货</strong>
                            </td>
                        </tr>
                        @Model.Order.OrderItems.Where(o => o.Status != OrderStatus.WaitBuyerConfirm).ToList().Each(@<tr>
                            <td title="@(item.Item.Title)">
                                <div class="media">
                                    <a class="pull-left" href="@(string.Format("{0}/{1}.html", WebSite.Item, item.Item.Id))" target="_blank">
                                        <img data-src="holder.js/64x64" class="media-object" alt="64x64" style="width: 64px;
                                            height: 64px;" src="">
                                    </a>
                                    <div class="media-body">
                                        <h5 class="media-heading">
                                            @(item.Item.Title)</h5>
                                        <div>
                                            @foreach (var x in item.Item.GetProperties().OrderBy(x => x.Length))
                                            {
                                                <span>@x</span>
                                                <br />
                                            }
                                        </div>
                                    </div>
                                </div>
                            </td>
                            <td>
                                @(item.Item.Price.ToString("N"))
                            </td>
                            <td>
                                @item.Item.Quantity
                            </td>
                            <td>
                                @item.Item.Discount.ToString("N")
                            </td>
                            <td>
                            </td>
                            <td style="border-right: 1px solid #D9D9D9">
                                d
                            </td>
                        </tr>)
                    </tbody>
                    <tfoot>
                        <tr>
                            <td colspan="7">
                                <p>
                                    买家留言：@(Model.Order.BuyerMessage)
                                </p>
                                <p class="pull-right">
                                    实付款： <span class="order-info-total-price">@(Model.Order.Total.ToString("N"))</span>
                                    元
                                </p>
                            </td>
                        </tr>
                    </tfoot>
                </table>
            }
            else if (Model.Order.Status == OrderStatus.WaitBuyerConfirm || Model.Order.Status == OrderStatus.Finished)
            {
                <table class="ui-table ui-table-alpha" style="border: none;">
                    <thead>
                        <tr>
                            <th style="width: 250px;">
                                商 品
                            </th>
                            <th>
                                单价(元)
                            </th>
                            <th>
                                数 量
                            </th>
                            <th>
                                优惠(元)
                            </th>
                            <th>
                                赠积分
                            </th>
                            <th>
                                状 态
                            </th>
                            <th>
                                实付款(元)
                            </th>
                        </tr>
                    </thead>
                    @if (Model.Order.ShippingType == ShippingType.Virtual)
                    {
                        <tbody>
                            @Model.Order.OrderItems.Each(@<tr>
                                <td title="@(item.Item.Title)">
                                    <div class="media">
                                        <a class="pull-left" href="@(string.Format("{0}/{1}.html", WebSite.Item, item.Item.Id))" target="_blank">
                                            <img data-src="holder.js/64x64" class="media-object" alt="64x64" style="width: 64px;
                                                height: 64px;" src="">
                                        </a>
                                        <div class="media-body">
                                            <h5 class="media-heading">
                                                @(item.Item.Title)</h5>
                                            <div>
                                                @foreach (var x in item.Item.GetProperties().OrderBy(x => x.Length))
                                                {
                                                    <span>@x</span>
                                                    <br />
                                                }
                                            </div>
                                        </div>
                                    </div>
                                </td>
                                <td>
                                    @(item.Item.Price.ToString("N"))
                                </td>
                                <td>
                                    @item.Item.Quantity
                                </td>
                                <td>
                                    @item.Item.Discount.ToString("N")
                                </td>
                                <td>
                                </td>
                                <td style="border-right: 1px solid #D9D9D9">
                                    @if (item.Item.Status == OrderStatus.Finished)
                                    {
                                        <p>
                                            <span>已确认收货
                                                @if (item.Item.ShippingType == ShippingType.Virtual && !item.Item.Extra.IsNullOrEmpty())
                                                {
                                                    <a href="javascript:void(0);" data-rel="popover" data-toggle="popover"
                                            data-trigger="hover" data-placement="left" data-title="虚拟发货" data-content="@(item.Item.Extra)">
                                                        <i class="icon-flag" style="color: red;"></i></a>
                                                }
                                            </span>
                                        </p>
                                    }
                                </td>
                                @if (item.Index == 0)
                                {
                                    <td rowspan="@(Model.Shippings.Count * 2 + Model.Order.OrderItems.Count)" >
                                        <p>
                                            <strong>@(Model.Order.Total.ToString("N"))</strong></p>
                                        @if (Model.Order.Postage == 0)
                                        {
                                            <p>
                                                <span>免运费</span></p>
                                        }
                                        else
                                        {
                                            <p>
                                                <span>含快递：@(Model.Order.Postage.ToString("N"))</span></p>
                                        }
                                        <p>
                                            <span>订单优惠：@(Model.Order.Discount.ToString("N"))</span></p>
                                    </td>
                                }
                            </tr>)
                        </tbody>
                    }
                    else
                    {
                        <tbody>
                            @{ var index = 1; }
                            @foreach (var o in Model.Shippings)
                            {
                                var ids = o.OrderItemIds.Split(',');
                                var items = Model.Order.OrderItems.Where(i => !i.IsVirtual && ids.Contains(i.Id.Trim())).ToList();
                                <tr>
                                    <td colspan="6" class="text-align-left" style="border-right: 1px solid #D9D9D9">
                                        @if (Model.Shippings.Count > 1)
                                        {
                                            <strong>包裹 @index</strong>
                                            <span class="pull-right">运单号：<strong>@(o.ExpressNo)</strong></span>
                                        }
                                        else
                                        {
                                            <span>运单号：<strong>@(o.ExpressNo)</strong></span>
                                        }
                                    </td>
                                    @if (index == 1)
                                    {
                                        <td rowspan="@(Model.Shippings.Count * 2 + Model.Order.OrderItems.Count)" >
                                            <p>
                                                <strong>@(Model.Order.Total.ToString("N"))</strong></p>
                                            @if (Model.Order.Postage == 0)
                                            {
                                                <p>
                                                    <span>免运费</span></p>
                                            }
                                            else
                                            {
                                                <p>
                                                    <span>含快递：@(Model.Order.Postage.ToString("N"))</span></p>
                                            }
                                            <p>
                                                <span>订单优惠：@(Model.Order.Discount.ToString("N"))</span></p>
                                        </td>
                                    }
                                </tr>
                                @items.Each(@<tr>
                                    <td title="@(item.Item.Title)">
                                        <div class="media">
                                            <a class="pull-left" href="@(string.Format("{0}/{1}.html", WebSite.Item, item.Item.Id))" target="_blank">
                                                <img data-src="holder.js/64x64" class="media-object" alt="64x64" style="width: 64px;
                                                    height: 64px;" src="">
                                            </a>
                                            <div class="media-body">
                                                <h5 class="media-heading">
                                                    @(item.Item.Title)</h5>
                                                <div>
                                                    @foreach (var x in item.Item.GetProperties().OrderBy(x => x.Length))
                                                    {
                                                        <span>@x</span>
                                                        <br />
                                                    }
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        @(item.Item.Price.ToString("N"))
                                    </td>
                                    <td>
                                        @item.Item.Quantity
                                    </td>
                                    <td>
                                        @item.Item.Discount.ToString("N")
                                    </td>
                                    <td>
                                    </td>
                                    <td style="border-right: 1px solid #D9D9D9">
                                        @if (item.Item.Status == OrderStatus.WaitBuyerConfirm)
                                        {
                                            <p>
                                                <span>商家已发货</span></p>
                                            <p>
                                                <a href="/order/confirm/@o.Id">确认收货</a></p>
                                        }
                                        @if (item.Item.Status == OrderStatus.Finished)
                                        {
                                            <p>
                                                <span>已确认收货</span></p>
                                        }
                                    </td>
                                </tr>)
                                <tr>
                                    <td colspan="6" class="text-align-left" style="border-right: 1px solid #D9D9D9">
                                        <p>
                                            收货人：@(o.Receiver)
                                            @(o.Mobile)
                                            @if (!o.Phone.IsNullOrEmpty())
                                            {
                                                @:（@(o.Phone)）
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                }
                                        </p>
                                        <p>
                                            收货地址：@(o.Province)
                                            @(o.City)
                                            @(o.District)
                                            @(o.Address)
                                            @(o.PostalCode)
                                        </p>
                                        <p>
                                            物流公司：@(o.Company)
                                        </p>
                                    </td>
                                </tr>
                                            index += 1;
                            }
                        </tbody>
                    }
                    <tfoot>
                        <tr>
                            <td colspan="7">
                                <p>
                                    买家留言：@(Model.Order.BuyerMessage)
                                </p>
                                <p class="pull-right">
                                    实付款： <span class="order-info-total-price">@(Model.Order.Total.ToString("N"))</span>
                                    元
                                </p>
                            </td>
                        </tr>
                    </tfoot>
                </table>
            }
        </div>
    </div>
</div>
@section css{
    <style type="text/css">
        .order-info-total-price { font-size: 18px; font-weight: normal; color: #c00; margin-right: 5px; }
        .alert h4 { font-size: 15px; color: #f60; margin-bottom: 5px; font-family: '微软雅黑'; }
        
        .radio.inline, .checkbox.inline { padding-top: 0; vertical-align: top; }
    </style>
}
@section js{
    <script type="text/javascript">
        $(function () {
            $('[data-rel="popover"]').popover();
        });
    </script>
}
